package com.lvkedu.dataforward.controller;


import com.lvkedu.dataforward.pojo.ReceiveData;
import com.lvkedu.dataforward.service.impl.ForwardServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping
public class ForwardController {

    @Autowired
    ForwardServiceImpl forwardService;

    /**
     * 接收传感器转发数据的接口
     * @param receiveDataList
     * @return
     */
    @PostMapping("/receiveData")
    public String receive(@RequestBody List<ReceiveData> receiveDataList) {
        System.out.println(receiveDataList);
        //接收的如果是数组，一个个处理
        for (int i = 0; i < receiveDataList.size(); i++){
            forwardService.handleReceiveDate(receiveDataList.get(i));
        }
        return "SUCCESS";
    }


}
